home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD-ROM Today - The Disc! 5
/
CD-ROM Today - The Disc (Issue 5)(November 1994).ISO
/
mac
/
Mac shareware
/
Education
/
RLaB
/
examples
/
ode_err.r
< prev
next >
Wrap
Text File
|
1994-09-21
|
810b
|
48 lines
#
# Perform integration tests to determine the effect
# of relerr, and abserr on the solution.
#
vdpol = function ( t , x )
{
local (xp)
xp = zeros(2,1);
xp[1] = x[1] * (1 - x[2]^2) - x[2];
xp[2] = x[1];
return xp;
};
t0 = 0;
tf = 10;
x0 = [0; 0.25];
dtout = 0.05;
relerr = [1e-6, 1e-5, 1e-4, 1e-3, 1e-2, 1e-1];
abserr = relerr;
#
# Baseline
#
xbase = ode( vdpol, 0, 20, x0, 0.05, 1e-9, 1e-9);
results = zeros (relerr.n, abserr.n);
elapse = zeros (relerr.n, abserr.n);
"start testing loop"
for (i in 1:abserr.n)
{
xode.[i] = <<>>;
for (j in 1:relerr.n)
{
printf("\t%i %i\n", i, j);
tic();
xode.[i].[j] = ode( vdpol, 0, 20, x0, 0.05, relerr[j], abserr[i]);
elapse[i;j] = toc();
# Save results
results[i;j] = max (max (abs (xode.[i].[j] - xbase)));
}
}
results